<template>
  <lb-layout
    class="tabs-content"
    v-loading="$store.getters.loading"
    element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="#a19f9fb0;"
    :paddBottom="5"
    :paddTop="0"
    :bottomHeight="120"
  >
    <lb-table
      :column="tableData.column"
      :data="tableData.data"
      border
      :height="740"
      pagination
      background
      layout="total, sizes, prev, pager, next, jumper"
      :page-sizes="[20, 40, 60, 80]"
      :pager-count="5"
      :current-page.sync="currentPage"
      :total="total"
      :page-size="pageSize"
      @size-change="handleSizeChange"
      @p-current-change="handleCurrentChange"
    >
    </lb-table>
  </lb-layout>
</template>

<script>
import { getCheckwaterlist } from "@/api/sensingEquipment/index.js";
export default {
  components: {},
  props: {
    id: {
      type: [Number, String],
      default: "",
    },
  },
  data() {
    return {
      currentPage: 1,
      pageSize: 20,
      total: 0,
      tableData: {
        column: [
          {
            prop: "checkTime",
            label: "巡检时间",
            width: 180,
            align: "center",
            showOverflowTooltip: true,
          },
          {
            prop: "name",
            label: "巡检人",
            minWidth: 100,
            align: "center",
            showOverflowTooltip: true,
          },
          {
            prop: "phoneNumber",
            label: "联系电话",
            minWidth: 100,
            align: "center",
            showOverflowTooltip: true,
          },
          {
            prop: "checkResult",
            label: "巡检结果",
            minWidth: 120,
            align: "center",
            showOverflowTooltip: true,
          },
        ],
        data: [],
      },
    };
  },
  created() {},
  mounted() {
    this.handlerSearchDetail();
  },
  methods: {
    async initData(data) {
      let that = this;
      let query = {
        // ...data,
      };
      query.id = this.id;
      query.pageNum = that.currentPage;
      query.pageSize = that.pageSize;
      that.$store.commit("app/updateApiCount", "add");
      await getCheckwaterlist(query)
        .then((res) => {
          that.$store.commit("app/updateApiCount");
          if (res.code === 700) {
            this.$message.warning(res.msg);
            return false;
          }
          that.tableData.data = res?.rows ?? [];
          that.total = res?.total ?? 0;
        })
        .catch((err) => {
          that.$store.commit("app/updateApiCount");
          // this.$message.error("系统错误,请联系管理员!");
        });
    },
    // 搜索
    handlerSearchDetail() {
      const data = {};
      this.initData(data);
    },
    handleSizeChange(val) {
      this.currentPage = 1;
      this.pageSize = val;
      this.handlerSearchDetail();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.handlerSearchDetail();
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
